package com.zsc.newbuds.mapper;

import com.zsc.newbuds.entity.DonationArea;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author D
 */
public interface DonationAreaMapper {


    /**
     * 增加捐赠区域
     * @param donationArea
     */
    @Options(useGeneratedKeys = true,keyProperty = "donationAreaId")
    @Insert("insert into donationArea(donation_area_city,donation_area_address) values(#{donationAreaCity},#{donationAreaAddress})")
    void addDonationArea(DonationArea donationArea);

    /**
     * 根据Id查询捐赠地区
     * @param id
     * @return
     */
    @Select("select * from donationArea where donation_area_id = #{id}")
    DonationArea getDonationAreaById(Integer id);


    /**
     * 获取所有捐赠地区
     * @return
     */
    @Select("select * from donationArea")
    List<DonationArea> getDonationAreaList();

    /**
     * 增加次数
     * @param id
     * @param times
     */
    @Update("update donationArea set donation_area_times = #{times} where donation_area_id = #{id}")
    void updateTimes(Integer id,int times);
}
